/*
 * Copyright 2015-2016 Amazon.com, Inc. or its affiliates.  All Rights Reserved.
 *
 * You may not use this file except in compliance with the terms and conditions set forth
 * in the accompanying LICENSE.TXT file.
 *
 * THESE MATERIALS ARE PROVIDED ON AN "AS IS" BASIS.  AMAZON SPECIFICALLY DISCLAIMS, WITH
 * RESPECT TO THESE MATERIALS, ALL WARRANTIES, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
 * THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
 */
package com.amazon.alexa.voicechrome.internal.views.util.wave;

import android.animation.Animator;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.util.AttributeSet;

public class SpeakingProgressView extends AnimatedAmplitudeView {
    public SpeakingProgressView(Context context) {
        super(context);
    }

    public SpeakingProgressView(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public SpeakingProgressView(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
    }

    public SpeakingProgressView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
        super(context, attrs, defStyleAttr, defStyleRes);
    }

    @Override
    protected Animator setUpAnimator() {
        // Scale the gradient up so there's no edge fade
        amplitudeView.setScaleX(4f);

        ObjectAnimator fadeOut = ObjectAnimator.ofFloat(amplitudeView, "alpha", 1, 0);
        fadeOut.setDuration(600);
        fadeOut.setRepeatCount(ValueAnimator.INFINITE);
        fadeOut.setRepeatMode(ValueAnimator.REVERSE);
        fadeOut.setAutoCancel(false);

        return fadeOut;
    }
}
